import streamlit as st
from douyin_get import DouYinGet
import pandas as pd
import os




st.title('抖音csv爬虫小程序')

search_name = st.text_input("请输入你想存储抖音热搜csv文件的文件名")
but = st.button("开始爬取")
crawl = DouYinGet(search_name)


if but:
    crawl.main()
    st.write("数据爬取完成!!!")

    csv_path = os.path.join('E:\\my_python_project\\zaodiaDP\\csv_file', f"{search_name}.csv")
    if csv_path:
        df = pd.read_csv(csv_path)
        st.dataframe(df)

with st.sidebar:
    but = st.button('登录')
    if but:
        crawl.login()



